<UserControl x:Class="Microsoft.PowerShell.CmdletManagement.SpecExamplesControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Microsoft.PowerShell.CmdletManagement" >

    <StackPanel>
        <GroupBox Header="Spec Examples">
            <StackPanel>
                <local:FreeTextExtendedTextBlock x:Name="SpecExamples" Label="Spec Examples"
                                                HelpText="Examples of this cmdlet in use"
                                                Value="{Binding Path=SpecExamples, Mode=TwoWay}"
                                                TextFontFamily="Lucida Console" 
                                                TextFontSize="10"
                                                MinLines="30"
                                                />
            </StackPanel>
        </GroupBox>
        <GroupBox Header="Help Examples">
            <StackPanel Name="HelpExamplesPanel">
                <ItemsControl x:Name="HelpExamples"
                               VirtualizingStackPanel.IsVirtualizing="False"
                              ItemsSource="{Binding Path=HelpExamples, Mode=TwoWay,
                              UpdateSourceTrigger=PropertyChanged}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <GroupBox>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="100"/>
                                        <ColumnDefinition Width="1"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition />
                                        <RowDefinition />
                                        <RowDefinition />
                                        <RowDefinition />
                                    </Grid.RowDefinitions>
                                    
                                    <Label Grid.Row="0" Grid.Column="0">Command</Label>
                                    <Grid Margin="5,1,15,2"
                                          Grid.Row="0" Grid.Column="2"
                                          >
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="50"/>
                                            <ColumnDefinition Width="1"/>
                                            <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>

                                        <TextBox
                                             Grid.Row="0"
                                             Grid.Column="0"
                                             FontFamily="Lucida Console"
                                             Background="#FF012456"
                                             Foreground="#FFEEEDF0"
                                             Text="C:\PS>" IsReadOnly="True" />

                                        <TextBox Grid.Row="0" Grid.Column="2"
                                                 MinLines="1"
						 MaxLines="7"
                                                 FontFamily="Lucida Console"
                                                 Background="#FF012456"
                                                 Foreground="#FFEEEDF0"
                                                 KeyDown="KeyDown_ChangeExample"
                                                 AcceptsReturn="True"
                                                 HorizontalScrollBarVisibility="Auto"
                                                 SpellCheck.IsEnabled="False"                                       
                                                 Text="{Binding Path=Command, Mode=TwoWay, 
                                                    UpdateSourceTrigger=PropertyChanged}" />

                                    </Grid>

                                    <Label Grid.Row="1" Grid.Column="0">Output</Label>
                                    <TextBox Margin="5,1,15,2"
                                             Grid.Row="1" Grid.Column="2"
                                             Name="HelpExampleOutput" 
                                             MinLines="3" 
                                             FontFamily="Lucida Console"
                                             Background="#FF012456"
                                             Foreground="#FFEEEDF0"
                                             KeyDown="KeyDown_ChangeExample"
                                             VerticalScrollBarVisibility="Auto"
                                             HorizontalScrollBarVisibility="Auto"
                                             AcceptsReturn="True"
                                             SpellCheck.IsEnabled="False"                                       
                                             Text="{Binding Path=Output, Mode=TwoWay, 
                                                    UpdateSourceTrigger=PropertyChanged}" />
                                    <Label Grid.Row="2" Grid.Column="0">Description</Label>
                                    <TextBox Margin="5,1,15,2"
                                             Grid.Row="2" Grid.Column="2"
                                             MinLines="3" 
                                             FontFamily="Lucida Console"
                                             Background="#FF012456"
                                             Foreground="#FFEEEDF0"
                                             TextWrapping="Wrap"
                                             KeyDown="KeyDown_ChangeExample"
                                             VerticalScrollBarVisibility="Auto"
                                             AcceptsReturn="True"
                                             SpellCheck.IsEnabled="True"                                       
                                             Text="{Binding Path=Description, Mode=TwoWay, 
                                                    UpdateSourceTrigger=PropertyChanged}" />
                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"
                                           Margin="5,0,15,0"
                                           Grid.Row="3" Grid.Column="2">
                                        <Button HorizontalAlignment="Right"
                                                Click="Click_AddExampleBefore" 
                                           Margin="0,0,5,0">
                                            New Example Before
                                        </Button>
                                        <Button HorizontalAlignment="Right"
                                                Click="Click_RemoveExample" 
                                           Margin="0,0,5,0">Delete this Example</Button>
                                        <Button HorizontalAlignment="Right"
                                                Click="Click_AddExampleAfter" 
                                           Margin="0,0,5,0">New Example After</Button>
                                </StackPanel>
                                </Grid>
                            </GroupBox>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <Label Margin="0,10,0,0">Add a New Example</Label>
                <Grid Margin="5,0,15,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="50"/>
                        <ColumnDefinition Width="1"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBox
                         Grid.Row="0"
                         Grid.Column="0"
                         FontFamily="Lucida Console"
                         Background="#FF012456"
                         Foreground="#FFEEEDF0"
                         Text="C:\PS>" IsReadOnly="True" />
                    <TextBox Name="NewExample"
                         Grid.Row="0"
                         Grid.Column="2"
                         LostFocus="LostFocus_AddExample"
                         KeyDown="KeyDown_AddExample"
                         MinLines="1"
                         FontFamily="Lucida Console"
                         Background="#FF012456"
                         Foreground="#FFEEEDF0"
                         HorizontalScrollBarVisibility="Auto"
                         VerticalScrollBarVisibility="Auto"
                         AcceptsReturn="False"
                         SpellCheck.IsEnabled="False" />
                </Grid>
            </StackPanel>
        </GroupBox>
    </StackPanel>
</UserControl>
